package leetcode3;

public class Day3 {

    public int removeElement(int[] nums, int val) {
        int len = nums.length-1;//记录数组最大下标

        for (int i = nums.length-1; i >=0; i--) {
            if(nums[i] == val) {
                if(i == len) {
                    len--;
                }else {
                    for(int j = i;j<len;j++) {
                        nums[j] = nums[j+1];
                    }
                    len--;
                }
            }
        }
        return len+1;
    }
}
